Skip to content

Conversation

@jwtowner
Copy link

@jwtowner jwtowner commented Mar 8, 2018

IMPORTANT: This PR should be applied only after PR #662 and #711
have first been applied.

The Android configure.sh shell script and CMake build files have
been updated for cpprestsdk on Android with the following changes:

  • Added new --api and --stl command line switches to the
    Build_android/configure.sh shell script that control the Android
    API level and C++ runtime to build against.
  • Added --boost and --openssl switches which allow the versions
    of Boost and OpenSSL to be specified.
  • Use the base CMake toolchain configuration files that come with
    Android NDK r13b and later if they are available (requires CMake
    3.6 or later to be installed on host system), otherwise fallback
    to using the older third-party android-cmake.
  • Fix a few compilation errors when building with libc++ on Android,
    namely to do with assumptions of using libstdc++ when the
    ANDROID or __ANDROID__ preprocessor definitions are defined.
  • Make use of the new features added in subsequent PRs for
    building OpenSSL and Boost for Android.

Note that cpprestsdk seems to no longer build with libstdc++ 4.8
or 4.9 library headers that ship with the Android NDKs due to the
use of std::to_string introduced in commit 6397261 so the default C++
runtime has been changed to c++_static in configure.sh for the time
being. This problem can probably be fixed in a separate patch, as its
outside of the scope of this PR.

Since the Xbox Live SDK is using Boost 1.59.0 on Android instead of
1.55.0, the configure script has been modified to use this version as
well by default.

Jesse Towner added 4 commits March 7, 2018 18:16
The Android configure.sh shell script and CMake build files have
been updated for cpprestsdk on Android with the following changes:

- Added new --api and --stl command line switches to the
  Android_build/configure.sh shell script that control the Android
  API level and C++ runtime to build against.
- Use the base CMake toolchain configuration files that come with
  Android NDK r13b and later if they are available (requires CMake
  3.6 or later to be installed on host system), otherwise fallback
  fallback to using the older third-party android-cmake.
- Fix a few compilation errors when building with libc++ on Android,
  namely to do with assumptions of using libstdc++ paired with
  checked the ANDROID or __ANDROID__ preprocessor symbols.
- Make use of the new features added in subsequent PRs for
  building OpenSSL and Boost for Android.

Note that cpprestsdk seems to no longer build with libstdc++ 4.8
or 4.9 library headers that ship with the Android NDKs due to the
use of std::to_string introduced in commit
6397261 so the default C++ runtime
has been changed to c++_static in configure.sh for the time being.
This problem can probably be fixed in a separate patch, as its
outside of the scope of this one.
the versions of these packages that are downloaded and built.

Furthermore, the default version of Boost has been upgraded to
1.59.0 as Boost 1.55.0 is no longer used by the Xbox Live SDK
on Android.
@aksswami
Copy link

aksswami commented Jun 4, 2018

Can we have some update on this PR? I am trying to build cpprest for android and facing issues while building.

@jwtowner Were you able to successfully build against > ndk 14 (Specially latest change with gcc to clang after ndk 16)

@jwtowner
Copy link
Author

@aksswami Yes, I was able to build against NDK r14b, but I had not with libstdc++ 4.9, you need to switch over to libc++ due to the use of std::to_string now. Unfortunately, the libc++ in r14b is stuck a v3.9. Recommend use NDK r17 if possible or maybe modifying cpprestsdk to not use std::to_string.

@BillyONeal
Copy link
Member

@jwtowner Sorry for the delay here -- I'm trying to take over this thing now and get Android builds added to continuous integration. It looks like Android builds are totally broken before these PRs, and things work OK if I apply all of them. Do you mind if that's applied as a single PR (here) and changes to add that to CI at the same time?

Thanks for the help!

BillyONeal added a commit to BillyONeal/cpprestsdk that referenced this pull request Oct 16, 2018
This merges parts of:
* PR microsoft#662 "Overhaul the build process for the OpenSSL dependency on
  Android" by jwtowner
* PR microsoft#711 "Update the build process for Boost on Android", also by
  jwtowner
* PR microsoft#714 "Improved the build process for cpprestsdk on Android", also
  by jwtowner.

The changes which required patching upstream Boost-for-Android in those
PRs has been stripped.

The NDK version targeted has been updated to 17c because that's what's
avaialble in Azure Pipelines.

Various compile failures this uncovered in cpprestsdk on Android were
fixed.
BillyONeal added a commit to BillyONeal/cpprestsdk that referenced this pull request Oct 18, 2018
* PR microsoft#662 "Overhaul the build process for the OpenSSL dependency on
  Android" by jwtowner
* PR microsoft#711 "Update the build process for Boost on Android", also by
  jwtowner
* PR microsoft#714 "Improved the build process for cpprestsdk on Android", also
  by jwtowner.

The changes which required patching upstream Boost-for-Android in those
PRs has been stripped.

The NDK version targeted has been updated to 17c because that's what's
avaialble in Azure Pipelines.

Various compile failures this uncovered in cpprestsdk on Android were
fixed.
BillyONeal added a commit that referenced this pull request Oct 18, 2018
* This merges parts of:
* PR #662 "Overhaul the build process for the OpenSSL dependency on
  Android" by jwtowner
* PR #711 "Update the build process for Boost on Android", also by
  jwtowner
* PR #714 "Improved the build process for cpprestsdk on Android", also
  by jwtowner.

The changes which required patching upstream Boost-for-Android in those
PRs has been stripped.

The NDK version targeted has been updated to 17c because that's what's
avaialble in Azure Pipelines.

Various compile failures this uncovered in cpprestsdk on Android were
fixed.

* Added Jesse Towner (jwtowner) to contributors.
@jwtowner
Copy link
Author

You caught me on vacation! Just getting back up to speed right now. Looks like you did the right thing in applying all of the PRs. We've been using this downstream for some time on Microsoft Solitaire Collection and few other projects in tandem with the XBox Live SDK, in order for us to use C++17 with NDK r15c and r16b when targeting Android. We will probably move to r17c or beyond when that becomes more viable with VS2019. As far as applying things upstream for Boost-For-Android, that's certainly a possibility but I have not reached out to the project retainer there. It looked like cpprestsdk had originally made modifications to it in its patch regardless so that felt like the best way to go for our needs.

If you have any further questions, I'd be more than happy to help clarify things.

@BillyONeal
Copy link
Member

It looked like cpprestsdk had originally made modifications to it in its patch regardless so that felt like the best way to go for our needs.

Right, I agree that made sense then. Now that we don't need to modify things any longer I would prefer to stay out of that business.

Do you mind if I mark these PRs closed now that we have regular Android builds in Azure Pipelines?

@jwtowner
Copy link
Author

Right, I agree that made sense then. Now that we don't need to modify things any longer I would prefer to stay out of that business.

Do you mind if I mark these PRs closed now that we have regular Android builds in Azure Pipelines?

Yes, I think it's safe to close them. Thanks for getting this merged in!

@BillyONeal BillyONeal closed this Oct 18, 2018
@BillyONeal
Copy link
Member

No, thank you for the contribution, and sorry it took so long :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants